package com.mao.adapterpattern.use;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.CharBuffer;

public class Real {

    public static void main(String[] args) {

        try {
            File file = new File("");
            long length = file.length();
            // 读取文件通过字节流
            InputStream inputStream =new FileInputStream(file);
            int available = inputStream.available();
            byte[] content = new byte[available];
            int read = inputStream.read(content);
            /**
             * 读取文件通过字符流  利用（对象）适配器模式将字节流读取inputstream适配至Inputstreamreader
             * 实现字节流读取文件的功能扩展
             *
              */

            InputStreamReader reader = new InputStreamReader(inputStream);
            char[] contentChar = new char[available];
            reader.read(contentChar);

        } catch (IOException e) {
            e.printStackTrace();
        }


    }

}
